using System;
using System.Web.UI.WebControls;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Web.Editors.ASPx;
using DevExpress.Web.ASPxEditors;
using FeatureCenter.Module.PropertyEditors;
using DevExpress.ExpressApp.Model;

namespace FeatureCenter.Module.Web.PropertyEditors {
	[PropertyEditor(typeof(DateTime), FeatureCenterEditorAliases.CustomDateTimeEditor, false)]
    public class CustomDateTimeEditor : ASPxDateTimePropertyEditor {
        public CustomDateTimeEditor(Type objectType, IModelMemberViewItem info) : base(objectType, info) { }

        protected override void SetupControl(WebControl control) {
            base.SetupControl(control);
            if (ViewEditMode == ViewEditMode.Edit) {
                ASPxDateEdit aspxcontrol = control as ASPxDateEdit;
                aspxcontrol.CalendarProperties.ShowWeekNumbers = false;
                aspxcontrol.CalendarProperties.ShowClearButton = false;
                aspxcontrol.CalendarProperties.ShowDayHeaders = false;
                aspxcontrol.CalendarProperties.EnableYearNavigation = false;
                aspxcontrol.CalendarProperties.EnableMonthNavigation = false;
                aspxcontrol.CalendarProperties.ShowTodayButton = false;
                aspxcontrol.MinDate = new DateTime(DateTime.Today.Year,
                    DateTime.Today.Month, 1);
                aspxcontrol.MaxDate = new DateTime(DateTime.Today.Year,
                    DateTime.Today.Month, DateTime.DaysInMonth(DateTime.Today.Year,
                    DateTime.Today.Month));
            }
        }
    }
}
